// 下载文件模块
function openBrowser(url) {
    new Promise((resolve, reject) => {
        let aLink = document.createElement('a');
        aLink.href = url;
        let evt = document.createEvent("MouseEvents");
        evt.initMouseEvent("click", false, false);
        aLink.dispatchEvent(evt);
    });
}

export function toDownFile(url) {
    const { platform } = weex.config.env;
    let platformName =  platform.toLowerCase();
    if (platformName === 'web') {
        openBrowser(url)
    } else if (platformName === 'android') {
        weex.requireModule('downFile').openBrowser(url)
    } else {
        weex.requireModule('modal').toast({
            message: platformName + '平台,暂时不支持下载'
        })
    }
}